package com.ygqh.baby.model;

import com.ygqh.baby.ao.PromotionStatus;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Random;

public class ProductBargainData {

    private Long bargainId;

    private String activeName;

    private BigDecimal targetPrice;

    private Integer countDown;

    private Integer buyCount;

    private String generationMode;

    private Integer cardCountDown;

    private Boolean cutOnlyNew;

    private BigDecimal expressPrice;

    private String platformNo;

    private Date startDate;

    private Date endDate;

    private Long bargainDetailId;

    private Long minCutCount;
    private Long maxCutCount;

    private Long stockQuantity;

    private Boolean realStock;

    private Long productId;
    private String productName;
    private String imagePath;
    private BigDecimal productPrice;

    public PromotionStatus getPromotionStatus() {
        if (startDate == null || endDate == null) {
            return PromotionStatus.Completed;
        }
        if (System.currentTimeMillis() > endDate.getTime()) {
            return PromotionStatus.Completed;
        } else if (System.currentTimeMillis() < startDate.getTime()) {
            return PromotionStatus.NotStarted;
        }
        return PromotionStatus.Running;
    }

    public Long getRandomCutCount() {
        Random random = new Random();
        int diff = maxCutCount.intValue() - minCutCount.intValue() + 1;
        int value = random.nextInt(diff);
        return minCutCount + value;
    }

    public Long getBargainId() {
        return bargainId;
    }

    public void setBargainId(Long bargainId) {
        this.bargainId = bargainId;
    }

    public String getActiveName() {
        return activeName;
    }

    public void setActiveName(String activeName) {
        this.activeName = activeName;
    }

    public BigDecimal getTargetPrice() {
        return targetPrice;
    }

    public void setTargetPrice(BigDecimal targetPrice) {
        this.targetPrice = targetPrice;
    }

    public Integer getCountDown() {
        return countDown;
    }

    public void setCountDown(Integer countDown) {
        this.countDown = countDown;
    }

    public Integer getBuyCount() {
        return buyCount;
    }

    public void setBuyCount(Integer buyCount) {
        this.buyCount = buyCount;
    }

    public String getGenerationMode() {
        return generationMode;
    }

    public void setGenerationMode(String generationMode) {
        this.generationMode = generationMode;
    }

    public Integer getCardCountDown() {
        return cardCountDown;
    }

    public void setCardCountDown(Integer cardCountDown) {
        this.cardCountDown = cardCountDown;
    }

    public BigDecimal getExpressPrice() {
        return expressPrice;
    }

    public void setExpressPrice(BigDecimal expressPrice) {
        this.expressPrice = expressPrice;
    }

    public String getPlatformNo() {
        return platformNo;
    }

    public void setPlatformNo(String platformNo) {
        this.platformNo = platformNo;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public Long getBargainDetailId() {
        return bargainDetailId;
    }

    public void setBargainDetailId(Long bargainDetailId) {
        this.bargainDetailId = bargainDetailId;
    }

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public Long getMinCutCount() {
        return minCutCount;
    }

    public void setMinCutCount(Long minCutCount) {
        this.minCutCount = minCutCount;
    }

    public Long getMaxCutCount() {
        return maxCutCount;
    }

    public void setMaxCutCount(Long maxCutCount) {
        this.maxCutCount = maxCutCount;
    }

    public Boolean getRealStock() {
        return realStock;
    }

    public void setRealStock(Boolean realStock) {
        this.realStock = realStock;
    }

    public Long getStockQuantity() {
        return stockQuantity;
    }

    public void setStockQuantity(Long stockQuantity) {
        this.stockQuantity = stockQuantity;
    }

    public Boolean getCutOnlyNew() {
        return cutOnlyNew;
    }

    public void setCutOnlyNew(Boolean cutOnlyNew) {
        this.cutOnlyNew = cutOnlyNew;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getImagePath() {
        return imagePath;
    }

    public void setImagePath(String imagePath) {
        this.imagePath = imagePath;
    }

    public BigDecimal getProductPrice() {
        return productPrice;
    }

    public void setProductPrice(BigDecimal productPrice) {
        this.productPrice = productPrice;
    }
}
